// ----- ARTIST PICTURE -----
$set_ps_global(do.artist.pic,$findfile($directory_path(%path%)\artist.*,
$if($findfile($replace(%path%,%filename_ext%,)artist.*),
$replace(%path%,%filename_ext%,)artist.*,
$if($findfile($replace(%path%,%filename_ext%,)%artist%.*),
$replace(%path%,%filename_ext%,)%artist%.*,
$if($findfile($replace(%path%,%filename_ext%,)folder.*),
$replace(%path%,%filename_ext%,)folder.*,
$if($findfile($replace(%path%,%filename_ext%,)front.*),
$replace(%path%,%filename_ext%,)front.*,
$if($findfile($replace(%path%,%filename_ext%,)cover.*),
$replace(%path%,%filename_ext%,)cover.*,)))))))

$set_ps_global(do.artist.alpha,32)

// ----- GLOBAL VARIABLES -----
$set_ps_global(do.buttons,%ps_foobar2000_path%\themes\DarkOne_v4.0\Images\)
$set_ps_global(do.images,%ps_foobar2000_path%\themes\DarkOne_v4.0\Images\)
$set_ps_global(do.colour,19-30-38-255)

$init_ps_global(do.playlist.switch,1)
$init_ps_global(do.display.switch,1)
$init_ps_global(do.panel.switch,1)
$init_ps_global(do.library.switch,1)
$init_ps_global(do.al.scroll,0)
$init_ps_global(do.fil.scroll,0)
$init_ps_global(do.time.switch,1)
$init_ps_global(do.clockspect.switch,1)

$puts(panel.w,$div($sub(%ps_width%,100),2))
$puts(btn.l,$min($sub($get(panel.w),34),$add($div($get(panel.w),1),310)))

// ----- PANEL MANAGEMENT -----
$showpanel_c(ELPlaylist,$ifequal(%do.playlist.switch%,1,1,0))
$showpanel_c(Playlist,$ifequal(%do.playlist.switch%,2,1,0))
$showpanel_c(MiniPlaylist,$ifequal(%do.playlist.switch%,3,1,0))
$showpanel_c(Spectrum,$ifequal(%do.clockspect.switch%,1,1,0))
$showpanel_c(Clock,$ifequal(%do.clockspect.switch%,2,1,0))
$showpanel_c(Scrolltxt,$ifequal(%do.clockspect.switch%,3,1,0))

$ifequal(%do.playlist.switch%,3,
	$movepanel_c(Cover,$max($muldiv(%ps_width%,31,128),310),108,$min($muldiv(%ps_width%,33,64),$sub(%ps_width%,620)),$sub(%ps_height%,118))
,
	$movepanel_c(Cover,$max($div(%ps_width%,128),10),$min($sub(%ps_height%,$add($muldiv(%ps_width%,7,32),10)),$sub(%ps_height%,290)),$max($muldiv(%ps_width%,7,32),280),$max($muldiv(%ps_width%,7,32),280))
)

$ifequal(%do.clockspect.switch%,1,
	$movepanel_c(Spectrum,$max($muldiv(%ps_width%,31,128),310),10,$min($muldiv(%ps_width%,33,64),$sub(%ps_width%,620)),70)
	$movepanel_c(Clock,0,0,0,0)
                $movepanel_c(Scrolltxt,0,0,0,0)
,
$ifequal(%do.clockspect.switch%,2,	
                $movepanel_c(Spectrum,0,0,0,0)
	$movepanel_c(Clock,$max($muldiv(%ps_width%,31,128),310),10,$min($muldiv(%ps_width%,33,64),$sub(%ps_width%,620)),70)
                $movepanel_c(Scrolltxt,0,0,0,0)
,	
$ifequal(%do.clockspect.switch%,3,            
                $movepanel_c(Spectrum,0,0,0,0)
	$movepanel_c(Clock,0,0,0,0)
                $movepanel_c(Scrolltxt,$max($muldiv(%ps_width%,31,128),310),10,$min($muldiv(%ps_width%,33,64),$sub(%ps_width%,620)),70)
,
)))

// -----BACKGROUND -----
$drawrect(0,0,%ps_width%,%ps_height%,%do.colour%,%do.colour%)
$gradientrect(0,0,%ps_width%,90,151-180-202-128,0-0-0-0)

// ----- BUTTONBAR BACKGROUND -----
$puts(center.x,$max($muldiv(%ps_width%,31,128),310))
$puts(center.w,$min($muldiv(%ps_width%,33,64),$sub(%ps_width%,620)))
$puts(switchback.x,$min($add($muldiv(%ps_width%,31,128),$sub($muldiv(%ps_width%,33,64),122)),$sub(%ps_width%,432)))

$drawrect($get(center.x),82,$get(center.w),24,76-121-153-32,76-121-153-48)
$imageabs($get(switchback.x),82,121,24,%do.images%PLSwitcherBack.png)

// ----- ARTIST PICTURE LAYER -----
$ifequal(%do.playlist.switch%,1,
	$if(%ps_isplaying%,
		$drawimage($get(center.x),108,$get(center.w),$sub(%ps_height%,118),%do.artist.pic%,wc,,%do.artist.alpha%)
	)
,
)

// ----- BUTTONS -----
$font(Arial Black,5,)
$drawtextex(DISPLAY      MODE,$get(btn.l),1,159,8,255-255-255,vcenter hcenter)
$imagebutton($get(panel.w),3,101,5,%do.images%\Clock_MH.png,%do.images%\Clock.png,$ifequal(%do.clockspect.switch%,3,SETGLOBAL:do.clockspect.switch :1,SETGLOBAL:do.clockspect.switch:$add(%do.clockspect.switch%,1));REFRESH)

// FAKE-BUTTON
$textbutton(0,2,1,1,,,CONTEXT:Main Menu/File/,,)

// PLAYLISTS
$puts(button.x,$min($add($muldiv(%ps_width%,31,128),$muldiv(%ps_width%,33,64)),$sub(%ps_width%,310)))

$imagebutton($sub($get(button.x),107),88,13,12,%do.buttons%EL$ifequal(%do.playlist.switch%,1,MH,).png,%do.buttons%ELMH.png,SETGLOBAL:do.playlist.switch:1;REFRESH,,)
$imagebutton($sub($get(button.x),67),88,13,12,%do.buttons%CPL$ifequal(%do.playlist.switch%,2,MH,).png,%do.buttons%CPLMH.png,SETGLOBAL:do.playlist.switch:2;REFRESH,,)
$imagebutton($sub($get(button.x),27),88,13,12,%do.buttons%BC$ifequal(%do.playlist.switch%,3,MH,).png,%do.buttons%BCMH.png,SETGLOBAL:do.playlist.switch:3;REFRESH,,)